package com.bw.zg2.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.bw.zh.Const
import com.bw.zg2.base.BaseResult
import com.bw.zg2.base.BaseViewModel
import com.bw.zh.bean.HomeBean
import com.bw.zh.bean.SecondBean
import com.bw.zh.bean.SecondItemBean
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 *
 * @ClassName: HomeViewModel
 * @Description: java类作用描述
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/14 11:49 AM
 * @Version: 1.0
 */
class HomeViewModel : BaseViewModel() {

    val homeLiveData = MutableLiveData<BaseResult<HomeBean>>()
    val secondLiveData = MutableLiveData<BaseResult<SecondBean>>()

    fun getHomeList() {
        //开启协程，发送网络请求
        viewModelScope.launch(Dispatchers.IO) {
            homeLiveData.postValue(apiService2.getHome(Const.URL_NEW_HOME))
        }

    }

    fun getSecond() {
        //开启协程，发送网络请求
        viewModelScope.launch(Dispatchers.IO) {
            secondLiveData.postValue(apiService2.getSecond(Const.URL_SECOND_HOS))
        }

    }
}